package com.jsmile.cloud.authc.sys.feign;

import javax.validation.Valid;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.jsmile.cloud.authc.api.req.ReqSysUserRegister;
import com.jsmile.cloud.authc.api.res.ResSysUser;
import com.jsmile.cloud.authc.sys.SysUserApplicationService;
import com.jsmile.mail.security.controller.AuthcController;
import com.jsmile.mall.api.JSmileResult;
import com.jsmile.mall.api.constants.JSmileConstant;
import com.jsmile.mall.api.enums.LogTypeEnum;
import com.jsmile.mall.log.annotation.JsmileLog;

import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@RestController
@Slf4j
@AllArgsConstructor
public class UserServiceApiImpl extends AuthcController {

    private final SysUserApplicationService sysUserApplicationService;

    @RequestMapping(value = "/feign/user/register", method = RequestMethod.POST)
    @JsmileLog(title = "用户中心->用户注册", type = LogTypeEnum.INSERT, systemId = JSmileConstant.SystemId.AUTHC)
    public JSmileResult<ResSysUser> register(@RequestBody @Valid ReqSysUserRegister sysUserRegister) {
        ResSysUser resSysUser = sysUserApplicationService.register(sysUserRegister);
        return JSmileResult.success(resSysUser);
    }

}
